#include "ProcessBar.h"

//download
double bandwidth = 1024*1024*1.0;

void download(double filesize, callback_t cb)
{
    double current = 0.0;

    printf("download begin, current: %lf\n", current);
    while (current <= filesize)
    {
        cb(filesize, current);
        //从网络中获取数据
        current += bandwidth;
        usleep(100000);
    }

    printf("\ndownload done, filesize: %lf\n", filesize);
}

int main()
{
    //ForTest();
    //ProcBar();
    //ProcBar(100.0, 99.9);
    download(1024*1024*100, ProcBar);
    download(1024*1024*10, ProcBar);
    download(1024*1024*3, ProcBar);
    download(1024*1024*56, ProcBar);

    return 0;
}
